package com.caidanxiaoyuan.util;

import java.io.PrintWriter;

import javax.servlet.http.HttpServletResponse;

public class ResponseUtil {
	public static void write(HttpServletResponse response, Object object) throws Exception {
		response.setContentType("text/html;charset=utf-8");
		PrintWriter out = response.getWriter();
		out.println(object);
		out.flush();
		out.close();
	}

	public static void result(HttpServletResponse response, String result) {
		try {
			response.setCharacterEncoding("utf-8");
			response.setContentType("application/json;charset=utf-8");
			response.setHeader("Pragma", "No-cache");
			response.setHeader("Cache-Control", "no-cache");
			response.setDateHeader("Expires", 0L);
			response.getWriter().write(result);
			response.getWriter().flush();
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
}